/*
 * Дерево Фенвика
 */

#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef DEBUG
# define debug_fprintf(x)	fprintf x
#else
# define debug_fprintf(x)	((void) 0)
#endif

#define S_assert(st) ((st)?((void)0):(void)fprintf(stderr,"Assertion (soft) \"%s\" in %s:%s():%d: failed.\n",#st,__FILE__,__func__,__LINE__))
#define SWAP_INT(a, b)	(((a) ^ (b)) && ((b) ^= (a) ^= (b), (a) ^= (b)))
#define MIN(a, b)	((a) < (b) ? (a) : (b))

#define FF(n)	(((n) & ((n) + 1)) - 1)
#define FB(n)	((n) | ((n) + 1))

struct fenwicktree {
	long long *data;
	long long *fwt;
	int n;
};

/* {{{ function prototypes */
/* memory allocation wrappers */
char *s_calloc(size_t n, size_t size);
char *s_malloc(size_t size);
char *s_realloc(char *oldptr, size_t newsize);
/* }}} */

/* {{{ memory allocation wrappers */
extern char *
s_calloc(size_t n, size_t size)
{
	void *ptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): calloc %lu times %lu bytes (tot %.4f MiB)\n",
			__func__, n, size, ((float) n * size) / (1024.0f * 1024.0f));
#endif /* MEMDEBUG */
	ptr = calloc(n, size);
	if (ptr == NULL) {
		fprintf(stderr, "%s(): out of memory, failed to allocate %lu bytes\n",
				__func__, n * size);
		abort();
	}
	return ptr;
}

extern char *
s_malloc(size_t size)
{
	void *ptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): malloc %lu bytes (%.4f MiB)\n",
			__func__, size, (float) size / (1024.0f * 1024.0f));
#endif /* MEMDEBUG */
	ptr = malloc(size);
	if (ptr == NULL) {
		fprintf(stderr, "%s(): out of memory, failed to allocate %lu bytes\n",
				__func__, size);
		abort();
	}
	return ptr;
}

extern char *
s_realloc(char *oldptr, size_t newsize)
{
	void *newptr;
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): realloc oldptr %p for new size of %lu (%.4f MiB)\n",
			__func__, oldptr, newsize, (float) newsize / (1024.0f * 1024.0f));
#endif
	newptr = realloc(oldptr, newsize);
	if (newptr == NULL) {
		fprintf(stderr, "%s(): out of memory, "
				"failed to realloc %p for new size of %lu bytes\n",
				__func__, oldptr, newsize);
		abort();
	}
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): newptr %p\n", __func__, newptr);
#endif /* MEMDEBUG */
	return newptr;
}

void
s_free(void *ptr)
{
#ifdef MEMDEBUG
	fprintf(stderr, "%s(): freeing %p\n", __func__, ptr);
#endif
	free(ptr);
}
/* }}} */

int
update(struct fenwicktree *F, const long long newval, const int idx)
{
	register long long diff;
	register int i = 0;

	i = idx;
	diff = newval - F->data[i];
	F->data[idx] = newval;

	while (i < F->n) {
		F->fwt[i] += diff;
		i = FB(i);
	}

	return 0;
}

long long
sum(struct fenwicktree *F, const int end)
{
	register int i = end;
	register long long res = 0;

	while (i >= 0) {
		res += F->fwt[i];
		i = FF(i);
	}

	return res;
}

long long
range_sum_incl(struct fenwicktree *F, const int start, const int end)
{
	return sum(F, end) - sum(F, start - 1);
}

int
main(int argc, char **argv)
{
	int op = 'A', x, y;
	struct fenwicktree F;
	static char input[1024];

	fgets(input, sizeof input - 1, stdin);
	sscanf(input, "%d %*d", &F.n);
	F.data = s_calloc(F.n, sizeof *F.data);
	F.fwt = s_calloc(F.n, sizeof *F.fwt);

	while (fgets(input, sizeof input - 1, stdin)) {
		if (sscanf(input, "%c %d %d", (char *) &op, &x, &y) != 3)
			break;

		switch (op) {
		case 'A':
			update(&F, y, x - 1);
			break;
		case 'Q':
			printf("%lld\n", range_sum_incl(&F, x - 1, y - 1));
			break;
		}
	}

	free(F.data);
	free(F.fwt);
	return 0;
}
